<%--
  Created by IntelliJ IDEA.
  User: dj
  Date: 2018-08-12
  Time: 7:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%@ include file="/common/baseMeta.jsp" %>
    <title>患者基本信息</title>

     <script type="text/javascript">
      var uid = "${sysStaffEntity.uid}";//唯一标识
      var lname = "${sysStaffEntity.lname}"; //登录工号
    $(function(){
        //控制高度
        $("#l_datagrid").height(findDimensions_height() - 50);
        $("#ICU_wxdjpd_List").height(findDimensions_height() - 50);
        $("#ICU_wxdjpd_Month").height(findDimensions_height() - 50); 
        //初始化表格
        initGrid();
        //加载表格数据
        LoadGrid(); 
		//初始化日期控件
		var myDate = new Date();
		$('#nd').val(myDate.getFullYear());
		$('#yf').val(myDate.getMonth()+1);
		//初始化选项卡
		$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
            e.target; // 当前切换的dom
            e.relatedTarget; // 先前切换的dom
			if ($(this).attr('id') == 'a1') { 
                $('#tabx2').hide();
                $('#tabx1').show();
			}
			if ($(this).attr('id') == 'a2') { 
                $('#tabx1').hide();
                $('#tabx2').show(); 
		        initICU_wxdjpd_MonthGrid();
				LoadICU_wxdjpd_MonthGrid();
			}
        });
		$.getJSON("/commapiV2", {p_dm: "sys_ks_GetzyICU", userid: lname}, function (data) {
                if (data.success) {
                    $("#ks").empty();
                    var option = "";
                    $(data.Table).each(function (index, row) {
                        option += "<option value='" + row.name + "'>" + row.name + "</option>";
                    });
                    $("#ks").append(option);
                }
            }, true);

    })
	//绑定评定患者明细
	function LoadICU_wxdjpd_ListGrid(dj,zs)
	{ 
		var postdata = {
            p_dm: "ICU_WXDJPD_GetList",
            pddj: dj,
            rq: $('#nd').val()+'-'+$('#yf').val()+'-01', 
			week:zs,
			pdks:$('#ks').val(),
        };
        //从API获取数据，并绑定
        $.getJSON("/commapiV2", postdata, function (data) {
            if (data.success) {
                var griddata = {};
                griddata.rows = data.Table;
                griddata.total = data.totalcount;
                $('#ICU_wxdjpd_List').datagrid('loadData', griddata);
            }
        });
	}
	//绑定评定总分值
	function LoadICU_wxdjpd_MonthGrid()
	{
		var postdata = {
            p_dm: "ICU_WXDJPD_GetMonth",
            pdks: $('#ks').val(),
            nd: $('#nd').val(),
            yf: $('#yf').val()
        };
        //从API获取数据，并绑定
        $.getJSON("/commapiV2", postdata, function (data) {
            if (data.success) {
                var griddata = {};
                griddata.rows = data.Table;
                griddata.total = data.totalcount;
                $('#ICU_wxdjpd_Month').datagrid('loadData', griddata);
            }
        });
	}
    function LoadGrid() {
        var postdata = {
            p_dm: "Thz_jbxx_GetICUhzinfo",
            zyh: $('#zyh').val(),
            hzxm: $('#hzxm').val(),
            userid: lname,
        };
        //从API获取数据，并绑定
        $.getJSON("/commapiV2", postdata, function (data) {
            if (data.success) {
                var griddata = {};
                griddata.rows = data.Table;
                griddata.total = data.totalcount;
                $('#l_datagrid').datagrid('loadData', griddata);
            }
        });
    }

    function initGrid() {
        $('#l_datagrid').datagrid({
            fit:false, //自动适屏功能
            rownumbers: true,//显示行号
            singleSelect: true,//只显示一行
            pagination: true,//启用分页
            remoteSort: false,
            clientPaging: false,
            fitColumns: true,
            sortable: true, //启用排序列
            collapsible: true,
            idField: 'blh',
            pageSize: 50,
            pageList: [50,  100, 150],
            columns: [
                [
                    {field: 'blh', title: '病例号', hidden: true},
                    {field: 'zyh', title: '住院号', width: '90px', align: 'center',
					  formatter: function(value,row,index){
                            return '<a style="color:blue" href="/HzinfoDisplay/Hzinfo_sxt?blh='+row.blh+'&zyh='+row.zyh+'" target="view_frame">'+row.zyh+'</a>';
                       }},
                    {field: 'zycs', title: '住院次数', width: '55px', align: 'center'},
                    {field: 'hzxm', title: '患者姓名', width: '90px', align: 'center'},
                    {field: 'xb', title: '性别', width: '45px', align: 'center'},
                    {field: 'hznl', title: '年龄', width: '45px', align: 'center'},
                    {field: 'rksj', title: '入科时间', width: '90px', align: 'center'},
                    {field: 'cwh', title: '床位号', width: '90px', align: 'center'},
                    {field: 'zgys', title: '主管医生', width: '120px', align: 'center'},
                    {field: 'ryzd', title: '入院诊断', width: '120px', align: 'center'},
                    {field: 'szks', title: '所在科室', width: '120px', align: 'center'}
                ]
            ]
        }).datagrid('clientPaging');
    }
	function initICU_wxdjpd_MonthGrid() {
        $('#ICU_wxdjpd_Month').datagrid({
            fit:false, //自动适屏功能
            rownumbers: true,//显示行号
            singleSelect: true,//只显示一行 
            remoteSort: false,
            clientPaging: false,
            fitColumns: true,
            sortable: true, //启用排序列
            collapsible: true,
            idField: 'dj',
            columns: [
                [
                    {field: 'dj', title: '病情等级', width: '90px', align: 'center'},
                    {field: '1', title: '第一周', width: '90px', align: 'center'},
                    {field: '2', title: '第二周', width: '90px', align: 'center'},
                    {field: '3', title: '第三周', width: '90px', align: 'center'},
                    {field: '4', title: '第四周', width: '90px', align: 'center'}
                ]
            ],
			onClickCell: function (index, field, value) {
                initICU_wxdjpd_ListGrid(); 
				var dj="";
				switch(index){
                    case 0: dj='A类';break;
                    case 1: dj='B类';break; 
                    case 2: dj='C类';break; 
                    case 3: dj='D类';break; 
                    case 4: dj='E类';break;
                }
                LoadICU_wxdjpd_ListGrid(dj,field);				
			}
        });
    }
	function initICU_wxdjpd_ListGrid() {
        $('#ICU_wxdjpd_List').datagrid({
            fit:false, //自动适屏功能
            rownumbers: true,//显示行号
            singleSelect: true,//只显示一行 
            remoteSort: false,
            clientPaging: false,
            fitColumns: true,
            sortable: true, //启用排序列
            collapsible: true,
            idField: 'id',
            columns: [
                [
                    {field: 'blh', title: '病例号', hidden: true},
                    {field: 'zyh', title: '住院号', width: '90px', align: 'center',
					  formatter: function(value,row,index){
                            return '<a style="color:blue" href="/HzinfoDisplay/Hzinfo_sxt?blh='+row.blh+'&zyh='+row.zyh+'" target="view_frame">'+row.zyh+'</a>';
                       }},
                    {field: 'hzxm', title: '患者姓名', width: '90px', align: 'center'},
                    {field: 'bqdj', title: '病情等级', width: '90px', align: 'center'},
                    {field: 'pdys', title: '评定人', width: '90px', align: 'center'},
                    {field: 'pdsj', title: '评定时间', width: '140px', align: 'center'},
					{field: 'operate', title: '操作', width: '75px', align: 'left',sortable:false, halign: 'center',
                        formatter:function(value,row,index){
                            var str= '<button type=\'button\' class=\'btn btn-primary bi-glyphicon\' onclick="editItem(\'' + row.id + '\')"><span class=\'glyphicon  glyphicon glyphicon-pencil\'></span></button>';
                                str+= '<button type=\'button\' class=\'btn btn-danger bi-glyphicon\' onclick="delItem(\'' + row.id + '\')"><span class=\'glyphicon glyphicon glyphicon-remove\'></span></button>';
                            return str;
                        }
                    }

                ]
            ]
        });
    }
	function editItem(id)
	{    
		var url = "/FormApi?mobanId=a7eec2e5-9b0c-489e-8abe-d2a30d0a930d&dataId=" + id;
        layeropen(800, 500, "危险等级评定", url);
		var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
	}
    function delItem(id)
	{  if (confirm('您确定要删除吗？')) {
		$.getJSON("/commapiV2", {
                    p_dm: "ICU_WXDJPD_Del",
                    id: id
                }, function (data) {
                        if (data.success) {
                            LoadICU_wxdjpd_MonthGrid();
                        }
                }, true);
	   }
	}
	function wxdjpd()
	{
        var row = $('#l_datagrid').datagrid('getSelected');
		var url = "/FormApi?mobanId=a7eec2e5-9b0c-489e-8abe-d2a30d0a930d&mDefaultValue_BLH=" + row.blh + "&mDefaultValue_ZYH=" + row.zyh + "&mDefaultValue_HZXM=" + row.hzxm+ "&mDefaultValue_PDKS=" + row.szks;
        layeropen(800, 500, "危险等级评定", url);
	}
        </script>
</head>
<body>

<div style="margin:0 5px; overflow: hidden;">
    <ul class="nav nav-tabs" role="tablist" id="mytab" style="font-size: 12px;">
        <li class="active"  ><a href="#r_datagrid_tab" data-toggle="tab" id="a1">在院患者</a></li>
        <li ><a href="#r_datagrid_mban_tab"  data-toggle="tab" id="a2">ICU危险等级评定</a></li>
    </ul>
    <div style="width:100%;float:left;display:inline-block;padding-top:10px;" id="tabx1">
    <div class="navheader form-inline" style="height:40px;margin-bottom: 0px;">
        <div class=" form-group">
            <label for="ZYNumber" style="padding:5px 10px 0 20px;">住院号</label>
            <input type="text" class="form-control" style="width:100px;" name="zyh" id="zyh"
                   placeholder="住院号"/>
            <label for="ZYNumber" style="padding:5px 10px 0 20px;">患者姓名</label>
            <input type="text" class="form-control" style="width:100px;" name="hzxm" id="hzxm"
                   placeholder="患者姓名"/>
            <button type="button" class="btn btn-success bi-btn-search" onclick="LoadGrid()">
                <span class="glyphicon glyphicon glyphicon-search"></span>
            </button>
        </div>
		<div class="btn-group-right">
                <div class="btn-group" role="group">
                    <button type="button" class="btn btn-default bi-btn-width90" onclick="wxdjpd()">危险等级评定</button> 
                    <button type="button" class="btn btn-default bi-btn-width90" >刷新病人列表</button> 
                </div>
            </div>
    </div>
        <table id="l_datagrid" class="datagrid" style="width:100%;height: 500px"  ></table>
    </div>
	<div style="width:100%;float:left;display:inline-block;padding-top:10px;" id="tabx2">
	    <div class=" form-group">
		<label for="ZYNumber" style="padding:5px 10px 0 20px;">科室</label>
        <select id="ks">
		</select>
		<label for="CYRQStart" style="padding:5px 10px 0 20px;">年度</label>
        <select id="nd"> 
		<option value='2017'>2017</option>
		<option value='2018'>2018</option>
		<option value='2019'>2019</option>
		<option value='2020'>2020</option>
		<option value='2021'>2021</option>
		<option value='2022'>2022</option> 
		</select> 
		<label for="CYRQStart" style="padding:5px 10px 0 20px;">月份</label>
        <select id="yf"> 
		<option value='1'>01</option>
		<option value='2'>02</option> 
		<option value='3'>03</option> 
		<option value='4'>04</option> 
		<option value='5'>05</option> 
		<option value='6'>06</option> 
		<option value='7'>07</option> 
		<option value='8'>08</option> 
		<option value='9'>09</option>  
		<option value='10'>10</option>  
		<option value='11'>11</option>  
		<option value='12'>12</option> 
		</select> 
		<button type="button" class="btn btn-success bi-btn-search" onclick="LoadICU_wxdjpd_MonthGrid()">
            <span class="glyphicon glyphicon glyphicon-search"></span>
        </button>
		</div>
		<div style="margin:0 5px; overflow: hidden; " >
<!--左边表格-->
        <div style="width:35%;float:left;display:inline-block;padding-right:5px;border-right:1px dotted #ccc;" >
            <table id="ICU_wxdjpd_Month" class="datagrid"  ></table>
	    </div>
        <div style="width:65%;float:left;display:inline-block;padding-right:5px;border-right:1px dotted #ccc;" >
            <table id="ICU_wxdjpd_List" class="datagrid"  ></table>
	    </div>
    </div>
</div>
</body>
</html>
